home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / 42 ƒ / 42 AltiVec Life / StupidWay.c < prev    next >
Encoding:
Text File  |  1999-06-26  |  14.8 KB  |  642 lines  |  [TEXT/CWIE]

  1. // StupidWay.c
  2. // Handle Life propagation the stupid, but simple way
  3. // Copyright ©1995 Michael D. Crawford.  All Rights Reserved.
  4. // 23 Jun 95 Mike Crawford crawford@scruznet.com
  5. //
  6. // Revision History:
  7. // 27 Apr 97    DGC    New today
  8.  
  9. #include <QDOffscreen.h>
  10. #include "LifeModule.h"
  11. #include "StupidWay.h"
  12. void draw_line(vector unsigned short line, vector unsigned char * ptr,Handle ThePrivateData);
  13.  
  14. typedef union
  15. {
  16.     vector unsigned char v;
  17.     unsigned char c;
  18. } vChar;
  19.  
  20. int __stupid_start(void);
  21. int __stupid_start(void)
  22. {
  23. }
  24.  
  25. OSErr PIDrawACell(Handle ThePrivateData,long x, long y)
  26. {
  27.     return 0;
  28. }
  29.  
  30. OSErr PICreateLife(Handle ThePrivateData,
  31.                 unsigned long    *life_base,
  32.                 short rowbytes,
  33.                 long color)
  34. {
  35.     if (ThePrivateData == nil)
  36.         return -1;
  37.         
  38.     SetHandleSize(ThePrivateData,sizeof(tStupidData));
  39.     if(!(((tStupidPtr)*ThePrivateData)->myDataTic = NewHandleClear(16*128)))
  40.     {
  41.         SetHandleSize(ThePrivateData, 0);
  42.         return -1;
  43.     }
  44.     if(!(((tStupidPtr)*ThePrivateData)->myDataToc = NewHandleClear(16*128)))
  45.     {
  46.         DisposeHandle(((tStupidPtr)*ThePrivateData)->myDataTic);
  47.         SetHandleSize(ThePrivateData, 0);
  48.         return -1;
  49.     }
  50.     
  51.     ((tStupidPtr)*ThePrivateData)->height = 128;
  52.     ((tStupidPtr)*ThePrivateData)->width = 128;
  53.     ((tStupidPtr)*ThePrivateData)->life_base = life_base;
  54.     ((tStupidPtr)*ThePrivateData)->rowbytes = rowbytes/4;
  55.     ((tStupidPtr)*ThePrivateData)->color = color;
  56.     ((tStupidPtr)*ThePrivateData)->tic = true;
  57.     return noErr;
  58. }
  59.  
  60. void PISetColor(Handle ThePrivateData, long color)
  61. {
  62.     ((tStupidPtr)*ThePrivateData)->color = color;
  63. }
  64.  
  65. OSErr PITrashLife(Handle ThePrivateData)
  66. {
  67.     if (ThePrivateData)
  68.     {
  69.         if (((tStupidPtr)*ThePrivateData)->myDataTic)
  70.         {
  71.             DisposeHandle(ThePrivateData);
  72.             ((tStupidPtr)*ThePrivateData)->myDataTic = 0;
  73.         }
  74.         if (((tStupidPtr)*ThePrivateData)->myDataToc)
  75.         {
  76.             DisposeHandle(ThePrivateData);
  77.             ((tStupidPtr)*ThePrivateData)->myDataToc = 0;
  78.         }
  79.     }
  80.     return noErr;
  81. }
  82.  
  83. OSErr PISetACell(Handle ThePrivateData,long x, long y, Boolean state)
  84. {
  85.     vChar myX;
  86.     
  87.     vector unsigned char vX, value;    
  88.     vector unsigned char temp = (vector unsigned char)(0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
  89.  
  90.     myX.c = x;
  91.     vX = vec_splat(myX.v,0);
  92.     
  93.     temp = vec_srl(temp,vX);
  94.     temp = vec_sro(temp,vX);
  95.     
  96.     if (((tStupidPtr)*ThePrivateData)->tic)
  97.     {
  98.         value =    ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataTic))[y];
  99.         if (state)
  100.             value = vec_or(value,temp);
  101.         else
  102.             value = vec_andc(value,temp);
  103.  
  104.         ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataTic))[y] = value;
  105.     }
  106.     else
  107.     {
  108.         value =    ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataToc))[y];
  109.         if (state)
  110.             value = vec_or(value,temp);
  111.         else
  112.             value = vec_andc(value,temp);
  113.  
  114.         ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataToc))[y] = value;
  115.     }
  116.     return noErr;
  117. }
  118.  
  119. Boolean PIReadACell(Handle ThePrivateData,long x, long y)
  120. {
  121.     vChar myX;
  122.     
  123.     vector unsigned char vX;    
  124.     vector unsigned char data;
  125.     vector unsigned char zero = (vector unsigned char)(0);
  126.     vector unsigned char temp = (vector unsigned char)(0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
  127.  
  128.     myX.c = x;
  129.     vX = vec_splat(myX.v,0);
  130.     
  131.     temp = vec_srl(temp,vX);
  132.     temp = vec_sro(temp,vX);
  133.     
  134.     if (((tStupidPtr)*ThePrivateData)->tic)
  135.         data = ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataTic))[y];
  136.     else
  137.         data = ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataToc))[y];
  138.         
  139.     data = vec_and(data,temp);
  140.     
  141.     return !vec_all_eq(data,zero);
  142. }
  143.  
  144.  
  145. OSErr PINextGeneration(Handle ThePrivateData)
  146. {
  147.     long    i;
  148.     vector unsigned char line0, line1, line2, bit0, bit1, bit2, carry0, carry1,temp;
  149.     vector unsigned char zero = (vector unsigned char)(0);
  150.     vector unsigned char one = (vector unsigned char)(-1);
  151.     vector unsigned char shiftOne = (vector unsigned char)(1);
  152.     
  153.     if (ThePrivateData == nil)
  154.         return -1;
  155.     
  156.     if (((tStupidPtr)*ThePrivateData)->myDataTic == nil)
  157.         return -1;
  158.         
  159.     
  160.     if (((tStupidPtr)*ThePrivateData)->tic)
  161.     {    
  162.         line0 = zero;
  163.         line1 = zero;
  164.         line2 = ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataTic))[0];
  165.             
  166.         for (i=0; i< 128; i++)
  167.         {
  168.             line0 = line1;
  169.             line1 = line2;
  170.             if (i!=127)
  171.                 line2 = ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataTic))[i+1];
  172.             else
  173.                 line2 = zero;
  174.                 
  175.             bit0 = zero;
  176.             bit1 = zero; 
  177.             bit2 = one;
  178.             
  179.             temp = line0;
  180.             carry0 = vec_and(bit0,temp);
  181.             bit0   = vec_xor(bit0,temp);
  182.             carry1 = vec_and(bit1,carry0);
  183.             bit1   = vec_xor(bit1,carry0);
  184.             bit2   = vec_xor(bit2,carry1);
  185.             
  186.             temp = vec_sll(line0,shiftOne);
  187.             carry0 = vec_and(bit0,temp);
  188.             bit0   = vec_xor(bit0,temp);
  189.             carry1 = vec_and(bit1,carry0);
  190.             bit1   = vec_xor(bit1,carry0);
  191.             bit2   = vec_xor(bit2,carry1);
  192.         
  193.             temp = vec_srl(line0,shiftOne);
  194.             carry0 = vec_and(bit0,temp);
  195.             bit0   = vec_xor(bit0,temp);
  196.             carry1 = vec_and(bit1,carry0);
  197.             bit1   = vec_xor(bit1,carry0);
  198.             bit2   = vec_xor(bit2,carry1);
  199.         
  200.             temp = vec_sll(line1,shiftOne);
  201.             carry0 = vec_and(bit0,temp);
  202.             bit0   = vec_xor(bit0,temp);
  203.             carry1 = vec_and(bit1,carry0);
  204.             bit1   = vec_xor(bit1,carry0);
  205.             bit2   = vec_xor(bit2,carry1);
  206.         
  207.             temp = vec_srl(line1,shiftOne);
  208.             carry0 = vec_and(bit0,temp);
  209.             bit0   = vec_xor(bit0,temp);
  210.             carry1 = vec_and(bit1,carry0);
  211.             bit1   = vec_xor(bit1,carry0);
  212.             bit2   = vec_xor(bit2,carry1);
  213.         
  214.             temp = line2;
  215.             carry0 = vec_and(bit0,temp);
  216.             bit0   = vec_xor(bit0,temp);
  217.             carry1 = vec_and(bit1,carry0);
  218.             bit1   = vec_xor(bit1,carry0);
  219.             bit2   = vec_xor(bit2,carry1);
  220.             
  221.             temp = vec_sll(line2,shiftOne);
  222.             carry0 = vec_and(bit0,temp);
  223.             bit0   = vec_xor(bit0,temp);
  224.             carry1 = vec_and(bit1,carry0);
  225.             bit1   = vec_xor(bit1,carry0);
  226.             bit2   = vec_xor(bit2,carry1);
  227.         
  228.             temp = vec_srl(line2,shiftOne);
  229.             carry0 = vec_and(bit0,temp);
  230.             bit0   = vec_xor(bit0,temp);
  231.             carry1 = vec_and(bit1,carry0);
  232.             bit1   = vec_xor(bit1,carry0);
  233.             bit2   = vec_xor(bit2,carry1);
  234.             
  235.             
  236.             bit1 = vec_and(bit1,bit2);
  237.             bit0 = vec_or(bit0,line1);
  238.             ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataToc))[i]    = vec_and(bit1,bit0);        
  239.         }
  240.         ((tStupidPtr)*ThePrivateData)->tic = false;
  241.     }
  242.     else
  243.     {    
  244.     
  245.         line0 = zero;
  246.         line1 = zero;
  247.         line2 = ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataToc))[0];
  248.             
  249.         for (i=0; i< 128; i++)
  250.         {
  251.             line0 = line1;
  252.             line1 = line2;
  253.             if (i!=127)
  254.                 line2 = ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataToc))[i+1];
  255.             else
  256.                 line2 = zero;
  257.                 
  258.             bit0 = zero;
  259.             bit1 = zero; 
  260.             bit2 = one;
  261.             
  262.             temp = line0;
  263.             carry0 = vec_and(bit0,temp);
  264.             bit0   = vec_xor(bit0,temp);
  265.             carry1 = vec_and(bit1,carry0);
  266.             bit1   = vec_xor(bit1,carry0);
  267.             bit2   = vec_xor(bit2,carry1);
  268.             
  269.             temp = vec_sll(line0,shiftOne);
  270.             carry0 = vec_and(bit0,temp);
  271.             bit0   = vec_xor(bit0,temp);
  272.             carry1 = vec_and(bit1,carry0);
  273.             bit1   = vec_xor(bit1,carry0);
  274.             bit2   = vec_xor(bit2,carry1);
  275.         
  276.             temp = vec_srl(line0,shiftOne);
  277.             carry0 = vec_and(bit0,temp);
  278.             bit0   = vec_xor(bit0,temp);
  279.             carry1 = vec_and(bit1,carry0);
  280.             bit1   = vec_xor(bit1,carry0);
  281.             bit2   = vec_xor(bit2,carry1);
  282.         
  283.             temp = vec_sll(line1,shiftOne);
  284.             carry0 = vec_and(bit0,temp);
  285.             bit0   = vec_xor(bit0,temp);
  286.             carry1 = vec_and(bit1,carry0);
  287.             bit1   = vec_xor(bit1,carry0);
  288.             bit2   = vec_xor(bit2,carry1);
  289.         
  290.             temp = vec_srl(line1,shiftOne);
  291.             carry0 = vec_and(bit0,temp);
  292.             bit0   = vec_xor(bit0,temp);
  293.             carry1 = vec_and(bit1,carry0);
  294.             bit1   = vec_xor(bit1,carry0);
  295.             bit2   = vec_xor(bit2,carry1);
  296.         
  297.             temp = line2;
  298.             carry0 = vec_and(bit0,temp);
  299.             bit0   = vec_xor(bit0,temp);
  300.             carry1 = vec_and(bit1,carry0);
  301.             bit1   = vec_xor(bit1,carry0);
  302.             bit2   = vec_xor(bit2,carry1);
  303.             
  304.             temp = vec_sll(line2,shiftOne);
  305.             carry0 = vec_and(bit0,temp);
  306.             bit0   = vec_xor(bit0,temp);
  307.             carry1 = vec_and(bit1,carry0);
  308.             bit1   = vec_xor(bit1,carry0);
  309.             bit2   = vec_xor(bit2,carry1);
  310.         
  311.             temp = vec_srl(line2,shiftOne);
  312.             carry0 = vec_and(bit0,temp);
  313.             bit0   = vec_xor(bit0,temp);
  314.             carry1 = vec_and(bit1,carry0);
  315.             bit1   = vec_xor(bit1,carry0);
  316.             bit2   = vec_xor(bit2,carry1);
  317.             
  318.             
  319.             bit1 = vec_and(bit1,bit2);
  320.             bit0 = vec_or(bit0,line1);
  321.             ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataTic))[i]    = vec_and(bit1,bit0);            
  322.         }
  323.         ((tStupidPtr)*ThePrivateData)->tic = true;
  324.     }
  325.     
  326.     return noErr;
  327. }
  328.  
  329. OSErr PIDrawBoard(Handle ThePrivateData)
  330. {
  331.     long    y, rowbytes;
  332.     vector unsigned char * data;
  333.     vector unsigned char * ptr;
  334.     vector unsigned char line;
  335.     
  336.     if (ThePrivateData == nil)
  337.         return 0;
  338.     
  339.     if (((tStupidPtr)*ThePrivateData)->myDataTic == nil)
  340.         return 0;
  341.  
  342.     data = (vector unsigned char *)(((tStupidPtr)*ThePrivateData)->life_base);
  343.     
  344.     rowbytes = ((tStupidPtr)*ThePrivateData)->rowbytes/4;
  345.     
  346.     for (y=0;y<128;y++)
  347.     {
  348.         ptr = data;
  349.         
  350.         if (((tStupidPtr)*ThePrivateData)->tic)
  351.         {
  352.             //DebugStr("\ptic");
  353.             line = ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataTic))[y];
  354.             draw_line((vector unsigned short) line, ptr, ThePrivateData);
  355.         }
  356.         else
  357.         {
  358.             //DebugStr("\ptoc");
  359.             line = ((vector unsigned char *)(*((tStupidPtr)*ThePrivateData)->myDataToc))[y];
  360.             draw_line((vector unsigned short) line, ptr, ThePrivateData);
  361.         }
  362.         data += rowbytes;
  363.     }
  364.     return noErr;
  365. }
  366.  
  367. void draw_line(vector unsigned short line, vector unsigned char * ptr,Handle ThePrivateData)
  368. {
  369.     long j = 0;
  370.     vector unsigned char cline;
  371.     vector unsigned char t1;
  372.     vector unsigned char t2;
  373.     vector unsigned char t3;
  374.     vector unsigned char t4;
  375.     vector unsigned char t5;
  376.     vector unsigned char out;
  377.     
  378.     vector unsigned char one = (vector unsigned char)(1);
  379.     vector unsigned char shift_1 = (vector unsigned char)(4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0);
  380.     vector unsigned char shift_2 = (vector unsigned char)(2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0);
  381.     vector unsigned char shift_3 = (vector unsigned char)(1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0);
  382.     vector unsigned char white = (vector unsigned char)(-1);
  383.     vector unsigned char color;
  384.     
  385.     color = *(vector unsigned char*)&(((tStupidPtr)*ThePrivateData)->color) ;
  386.     
  387.     color = (vector unsigned char)vec_splat((vector unsigned long)color,0);
  388.     
  389.     cline = (vector unsigned char)line;
  390.     
  391.     t1 = vec_mergeh(cline,cline);
  392.     t1 = vec_sr(t1,shift_1);
  393.     {
  394.         t2 = vec_mergeh(t1,t1);
  395.         t2 = vec_sr(t2,shift_2);
  396.         {
  397.             t3 = vec_mergeh(t2,t2);
  398.             t3 = vec_sr(t3,shift_3);
  399.  
  400.             t3 = vec_and(t3,one);
  401.             t3 = (vector unsigned char)vec_cmpeq(t3,one);
  402.             {        
  403.                 t4 = vec_mergeh(t3,t3);
  404.                 {        
  405.                     t5 = vec_mergeh(t4,t4);
  406.                     out = vec_sel(white,color, t5);
  407.                     ptr[j++] = out;
  408.  
  409.                     t5 = vec_mergel(t4,t4);
  410.                     out = vec_sel(white,color, t5);
  411.                     ptr[j++] = out;
  412.                 }
  413.                 t4 = vec_mergel(t3,t3);
  414.                 {        
  415.                     t5 = vec_mergeh(t4,t4);
  416.                     out = vec_sel(white,color, t5);
  417.                     ptr[j++] = out;
  418.  
  419.                     t5 = vec_mergel(t4,t4);
  420.                     out = vec_sel(white,color, t5);
  421.                     ptr[j++] = out;
  422.                 }
  423.             }
  424.  
  425.             t3 = vec_mergel(t2,t2);
  426.             t3 = vec_sr(t3,shift_3);
  427.  
  428.             t3 = vec_and(t3,one);
  429.             t3 = (vector unsigned char)vec_cmpeq(t3,one);
  430.             {        
  431.                 t4 = vec_mergeh(t3,t3);
  432.                 {        
  433.                     t5 = vec_mergeh(t4,t4);
  434.                     out = vec_sel(white,color, t5);
  435.                     ptr[j++] = out;
  436.  
  437.                     t5 = vec_mergel(t4,t4);
  438.                     out = vec_sel(white,color, t5);
  439.                     ptr[j++] = out;
  440.                 }
  441.                 
  442.                 t4 = vec_mergel(t3,t3);
  443.                 {        
  444.                     t5 = vec_mergeh(t4,t4);
  445.                     out = vec_sel(white,color, t5);
  446.                     ptr[j++] = out;
  447.  
  448.                     t5 = vec_mergel(t4,t4);
  449.                     out = vec_sel(white,color, t5);
  450.                     ptr[j++] = out;
  451.                 }
  452.             }
  453.         }
  454.  
  455.         t2 = vec_mergel(t1,t1);
  456.         t2 = vec_sr(t2,shift_2);
  457.         {
  458.             t3 = vec_mergeh(t2,t2);
  459.             t3 = vec_sr(t3,shift_3);
  460.  
  461.             t3 = vec_and(t3,one);
  462.             t3 = (vector unsigned char)vec_cmpeq(t3,one);
  463.             {        
  464.                 t4 = vec_mergeh(t3,t3);
  465.                 {        
  466.                     t5 = vec_mergeh(t4,t4);
  467.                     out = vec_sel(white,color, t5);
  468.                     ptr[j++] = out;
  469.  
  470.                     t5 = vec_mergel(t4,t4);
  471.                     out = vec_sel(white,color, t5);
  472.                     ptr[j++] = out;
  473.                 }
  474.                 
  475.                 t4 = vec_mergel(t3,t3);
  476.                 {        
  477.                     t5 = vec_mergeh(t4,t4);
  478.                     out = vec_sel(white,color, t5);
  479.                     ptr[j++] = out;
  480.  
  481.                     t5 = vec_mergel(t4,t4);
  482.                     out = vec_sel(white,color, t5);
  483.                     ptr[j++] = out;
  484.                 }
  485.             }
  486.             t3 = vec_mergel(t2,t2);
  487.             t3 = vec_sr(t3,shift_3);
  488.  
  489.             t3 = vec_and(t3,one);
  490.             t3 = (vector unsigned char)vec_cmpeq(t3,one);
  491.             {        
  492.                 t4 = vec_mergeh(t3,t3);
  493.                 {        
  494.                     t5 = vec_mergeh(t4,t4);
  495.                     out = vec_sel(white,color, t5);
  496.                     ptr[j++] = out;
  497.  
  498.                     t5 = vec_mergel(t4,t4);
  499.                     out = vec_sel(white,color, t5);
  500.                     ptr[j++] = out;
  501.                 }
  502.                 
  503.                 t4 = vec_mergel(t3,t3);
  504.                 {        
  505.                     t5 = vec_mergeh(t4,t4);
  506.                     out = vec_sel(white,color, t5);
  507.                     ptr[j++] = out;
  508.  
  509.                     t5 = vec_mergel(t4,t4);
  510.                     out = vec_sel(white,color, t5);
  511.                     ptr[j++] = out;
  512.                 }
  513.             }
  514.         }
  515.  
  516.     }
  517.  
  518.     t1 = vec_mergel(cline,cline);
  519.     t1 = vec_sr(t1,shift_1);
  520.     {
  521.         t2 = vec_mergeh(t1,t1);
  522.         t2 = vec_sr(t2,shift_2);
  523.         {
  524.             t3 = vec_mergeh(t2,t2);
  525.             t3 = vec_sr(t3,shift_3);
  526.  
  527.             t3 = vec_and(t3,one);
  528.             t3 = (vector unsigned char)vec_cmpeq(t3,one);
  529.             {        
  530.                 t4 = vec_mergeh(t3,t3);
  531.                 {        
  532.                     t5 = vec_mergeh(t4,t4);
  533.                     out = vec_sel(white,color, t5);
  534.                     ptr[j++] = out;
  535.  
  536.                     t5 = vec_mergel(t4,t4);
  537.                     out = vec_sel(white,color, t5);
  538.                     ptr[j++] = out;
  539.                 }
  540.                 
  541.                 t4 = vec_mergel(t3,t3);
  542.                 {        
  543.                     t5 = vec_mergeh(t4,t4);
  544.                     out = vec_sel(white,color, t5);
  545.                     ptr[j++] = out;
  546.  
  547.                     t5 = vec_mergel(t4,t4);
  548.                     out = vec_sel(white,color, t5);
  549.                     ptr[j++] = out;
  550.                 }
  551.             }
  552.             t3 = vec_mergel(t2,t2);
  553.             t3 = vec_sr(t3,shift_3);
  554.  
  555.             t3 = vec_and(t3,one);
  556.             t3 = (vector unsigned char)vec_cmpeq(t3,one);
  557.             {        
  558.                 t4 = vec_mergeh(t3,t3);
  559.                 {        
  560.                     t5 = vec_mergeh(t4,t4);
  561.                     out = vec_sel(white,color, t5);
  562.                     ptr[j++] = out;
  563.  
  564.                     t5 = vec_mergel(t4,t4);
  565.                     out = vec_sel(white,color, t5);
  566.                     ptr[j++] = out;
  567.                 }
  568.                 
  569.                 t4 = vec_mergel(t3,t3);
  570.                 {        
  571.                     t5 = vec_mergeh(t4,t4);
  572.                     out = vec_sel(white,color, t5);
  573.                     ptr[j++] = out;
  574.  
  575.                     t5 = vec_mergel(t4,t4);
  576.                     out = vec_sel(white,color, t5);
  577.                     ptr[j++] = out;
  578.                 }
  579.             }
  580.         }
  581.         t2 = vec_mergel(t1,t1);
  582.         t2 = vec_sr(t2,shift_2);
  583.         {
  584.             t3 = vec_mergeh(t2,t2);
  585.             t3 = vec_sr(t3,shift_3);
  586.  
  587.             t3 = vec_and(t3,one);
  588.             t3 = (vector unsigned char)vec_cmpeq(t3,one);
  589.             {        
  590.                 t4 = vec_mergeh(t3,t3);
  591.                 {        
  592.                     t5 = vec_mergeh(t4,t4);
  593.                     out = vec_sel(white,color, t5);
  594.                     ptr[j++] = out;
  595.  
  596.                     t5 = vec_mergel(t4,t4);
  597.                     out = vec_sel(white,color, t5);
  598.                     ptr[j++] = out;
  599.                 }
  600.                 
  601.                 t4 = vec_mergel(t3,t3);
  602.                 {        
  603.                     t5 = vec_mergeh(t4,t4);
  604.                     out = vec_sel(white,color, t5);
  605.                     ptr[j++] = out;
  606.  
  607.                     t5 = vec_mergel(t4,t4);
  608.                     out = vec_sel(white,color, t5);
  609.                     ptr[j++] = out;
  610.                 }
  611.             }
  612.             t3 = vec_mergel(t2,t2);
  613.             t3 = vec_sr(t3,shift_3);
  614.  
  615.             t3 = vec_and(t3,one);
  616.             t3 = (vector unsigned char)vec_cmpeq(t3,one);
  617.             {        
  618.                 t4 = vec_mergeh(t3,t3);
  619.                 {        
  620.                     t5 = vec_mergeh(t4,t4);
  621.                     out = vec_sel(white,color, t5);
  622.                     ptr[j++] = out;
  623.  
  624.                     t5 = vec_mergel(t4,t4);
  625.                     out = vec_sel(white,color, t5);
  626.                     ptr[j++] = out;
  627.                 }
  628.                 
  629.                 t4 = vec_mergel(t3,t3);
  630.                 {        
  631.                     t5 = vec_mergeh(t4,t4);
  632.                     out = vec_sel(white,color, t5);
  633.                     ptr[j++] = out;
  634.  
  635.                     t5 = vec_mergel(t4,t4);
  636.                     out = vec_sel(white,color, t5);
  637.                     ptr[j++] = out;
  638.                 }
  639.             }
  640.         }
  641.     }
  642. }